<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>密码找回</title>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-touch-fullscreen" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="format-detection" content="address=no">
		<link rel="stylesheet" type="text/css" href="css/common.css">
		<link rel="stylesheet" type="text/css" href="css/index.css">
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" href="css/reset.css"> 
		<link rel="stylesheet" href="css/center-vip.css">
		<link rel="stylesheet" href="css/iconfont.css">
		<link rel="stylesheet" href="css/user-information.css">
		<script type="text/javascript" src="js/mui.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/iscroll.js"></script>
		<script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
		<script type="text/javascript" src="js/hmt.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/util.js"></script>
	</head>

	<body>
		<!--header star-->
		<header class="hasManyCity hasManyCitytwo" id="header">
			<a href="security.html" class="fl fanhui"><i class="iconfont icon-fanhui"></i></a>
			<div class="header-tit">密码找回</div>
		</header>
				
				<!--个人资料区域-->
			<ul class="mui-table-view">
				<form >
			        <li class="mui-table-view-cell" style="margin-top: 50px;">
			            <p class="font" style="text-align: left;">请输入帐号:</p>
			            <input type="text" id="username" onkeyup="value=value.replace(/[^\w\.]/ig,'')" name="username" data-role="none"
			            	 style="margin-left: 90px; width: 200px; font-size: 16px; border: none; " />
			            <button id='toastBtn' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">发送邮件</button>
			        </li>
			        <li class="mui-table-view-cell">
			            <p class="font">邮箱验证码:</p>
			            <input type="text" class="input"/>
			        </li>
			        
			        <li class="mui-table-view-cell">
			            <p class="font">新密码:</p>
			            <input type="password" class="input" id="password" name="password" data-role="none"/>
			        </li>
			        <li class="mui-table-view-cell">
			            <p class="font">确认密码:</p>
			            <input type="password" class="input" id="password2" data-role="none"/>
			        </li>
		    </ul>
		</form>
				
			<!--底部区域-->
			<div class="user-bt0">
				<button type="submit" onclick="checkForm()" class="user-bt1" data-ajax="false" data-role="none">确定</button>
			</div>
	</body>
	
	
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript">
	/*var options = $("#security").find("option:checked");
	console.log(options[0]);*/
	document.body.addEventListener('touchmove', function(event) {	
	    // 判断默认行为是否可以被禁用
	    if (event.cancelable) {
	        // 判断默认行为是否已经被禁用
	        if (!event.defaultPrevented) {
	            event.preventDefault();
	        }
	    }			
	}, false);
	//创建提示操作对象
	
	var param = {title:'提示',text:'',callback:function(){this.remove();}}
	
	/*$("#security").on('change',function(){
		var options = $("#security option:checked");
		console.log(options);
		console.log(options.val());
	});*/
	//绑定点击事件,确定
	function checkForm(){
		alert();
		var username = $("#username").val();
		console.log(username);
		if(!username){
			param.text = "请输入帐号！";
			iAlert(param);
			return;
		}
		console.log(checkUsername());
		var flag = checkemail()&&checkUsername();
		console.log(flag);
		if(flag){
			var data = $('form').serialize();
			console.log(data);
			$.ajax({
				"url": "http://192.168.0.150/WBPlatform/user/sendMail.do",
				"data": data,
				"type": "POST", 
				"dataType": "json", 
				"xhrFields": {
           			withCredentials: true
       			},
       			"crossDomain": true,
				"success": function(obj) {
					
					if(obj.state==1){
						param.text = obj.message;
						iAlert(param);
						location.href="#";
					}else{
						param.text = obj.message;
						iAlert(param);
					}
				}
			});
		}
	};
	//验证密码是否一致
	function checkPwd(){
		var pwd = $("#password").val();
		var pwd2 = $("#password2").val();
		if(pwd && pwd == pwd2){
			return true;
		}
		param.text = "两次输入的密码不一致！";
		iAlert(param);
		return false;
	}
			
	//按键返回与策划返回		
	document.addEventListener("plusready", function() {
    	// 注册返回按键事件
    	plus.key.addEventListener('backbutton', function() {
        	// 事件处理
    		window.history.back();
    	}, false);
	});
	    	
	//账号验证
	function checkUsername(){
		var username = $("#username").val();
		if(!username){
			param.text = "请输入账号！";
			iAlert(param);
			return false;
		}else{
			var flag=false;
			$.ajax({
				"url": "http://192.168.0.150/WBPlatform/user/check_username.do",
				"data": "username=" + username,
				"type": "GET", 
				"dataType": "json", 
				"async": false,
				"xhrFields": {
           			withCredentials: true
       			},
       			"crossDomain": true,
				"success": function(obj) {
					if(obj.state==1){
						console.log(obj.message);
						flag = true;
					}else{
						param.text = obj.message;
						iAlert(param);
					}
				}
			});
			return flag;
		}
	};
	//弹出邮件消息
	document.getElementById("toastBtn").addEventListener('tap', function() {
			var username = $("#username").val();
			alert("1");
			$.ajax({
				type:"post",
				url:"http://192.168.0.150/WBPlatform/user/sendMail.do",
				"data": "username=" + username,
				async:false,
				"dataType": "json",
				"xhrFields": {
	       			withCredentials: true
	   			},
	   			"crossDomain": true,
	   			"success": function(obj){
	   				if(obj.state==1){
	   					mui.toast(obj.message);
	   				} else {
	   					mui.toast(obj.message);
	   				} 
	   			}
			});
	});
	</script>
</html>